package com.itheima.service.impl;

import com.itheima.domain.User;
import com.itheima.mapper.UserMapper;
import com.itheima.service.UserService;
import com.itheima.utils.MapperUtils;

import java.util.List;

public class UserServiceImpl implements UserService {
    private UserMapper userMapper= MapperUtils.getMapper(UserMapper.class);
    @Override
    public List<User> findAll() {
        List<User> list = userMapper.findAll();
        MapperUtils.close();
        return list;
    }

    @Override
    public void add(User user) {
        userMapper.add(user);
        MapperUtils.close();
    }

    @Override
    public void delete(Integer[] ids) {
        if(ids != null && ids.length > 0) {
            userMapper.delete(ids);
            MapperUtils.close();
        }

    }

    @Override
    public User findById(int uid) {
        User user= userMapper.findById(uid);
        MapperUtils.close();
        return user;
    }

    @Override
    public void update(User user) {
        userMapper.update(user);
        MapperUtils.close();
    }

}
